from __future__ import annotations

from dataclasses import dataclass


@dataclass
class ShoringDesign:
    lateral_pressure_kPa: float
    strut_axial_kN: float
    wale_bending_kNm: float
    note: str


def design_simple_shoring(
    excavation_depth_m: float,
    soil_unit_weight_kN_m3: float = 18.0,
    active_coeff: float = 0.33,
    strut_spacing_m: float = 2.0,
    wale_span_m: float = 3.0,
) -> ShoringDesign:
    """土压力支护简化设计。

    采用线性分布的主动土压力 p = K_a·γ·H；
    取等效均布到支撑与围檩：
    - 支撑轴力 N ≈ p_avg × s × H
    - 围檩弯矩 M ≈ p_avg × L^2 / 8
    """

    H = excavation_depth_m
    p_max = active_coeff * soil_unit_weight_kN_m3 * H
    p_avg = 0.5 * p_max
    N = p_avg * strut_spacing_m * H
    M = p_avg * (wale_span_m ** 2) / 8.0
    return ShoringDesign(
        lateral_pressure_kPa=p_max,
        strut_axial_kN=N,
        wale_bending_kNm=M,
        note="简化估算，需按JGJ120等规范进行构造与复核",
    )


